package com.Lixiaoqian.CardPlay.common.customview;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import com.Lixiaoqian.CardPlay.R;


public class CustomDialogFragment extends DialogFragment {
	private static CustomDialogFragment f;
	public static CustomDialogFragment newInstance(int type) {
		if (f==null){
			f= new CustomDialogFragment();
		}
		Bundle bundle = new Bundle();
		bundle.putInt("type", type);
		f.setArguments(bundle);
		return f;
	}

	private int type = 0;
	private TextView tvContent;

	public CustomDialogFragment() {
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle bd = getArguments();
		this.type = bd.getInt("type", 0);

		// 可以设置dialog的显示风格，如style为STYLE_NO_TITLE，将被显示title。遗憾的是，我没有在DialogFragment中找到设置title内容的方法。theme为0，表示由系统选择合适的theme。
		// int style = DialogFragment.STYLE_NORMAL, theme = 0;
		// setStyle(style, theme);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		if (getDialog() != null) {
			getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
			getDialog().getWindow().setBackgroundDrawableResource(
					android.R.color.transparent);
		}

		View layout1 = inflater.inflate(R.layout.dialog_fragment_layout,
				container, false);

		tvContent = (TextView) layout1.findViewById(R.id.tv_dialog_content);

		return layout1;
	}

}
